<?php
    require('./Utils.php');

    $post = getJsonParamter();

    $username = $post['username'];
    $oldPwd = $post['oldPwd'];
    $newPwd = $post['newPwd'];

    $conn = getConnection();
    $sql = "UPDATE user SET password = ? WHERE username = ? AND password = ?";

    $result = execute($conn, $sql, $newPwd, $username, $oldPwd);

    if($result){
        getJson(200, '密码修改成功', null);
    }else{
        getJson(500, '密码修改失败,用户名或密码错误', null);
    }
?>